using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using FutureOpen.Core.func.sql;
using FutureOpen.Core.func.util;
using FutureOpen.Web.Pages;
using System.Text;

public partial class controls_GroupList : System.Web.UI.UserControl
{
    private PageBase pbase;
    private int cid;

    protected void Page_Load(object sender, EventArgs e)
    {
        pbase = (PageBase)this.Page;
        pbase.PageInit();
        cid = pbase.catid;

        if (!Page.IsPostBack)
        {
            AspNetPager1.PageSize = 20;
            if (cid > 0)
            {
                AspNetPager1.RecordCount = GroupProvider.GetGroupByCatCount(cid);
            }
            else
            {
                AspNetPager1.RecordCount = GroupProvider.GetGroupCount(); 
            }
            LoadGroups(0, 20);
        }
    }
    public void LoadGroups(int start, int end)
    {
        DataSet ds = null;
        if (this.cid > 0)
        {
            ds = GroupProvider.GetGroupByCat(cid, start, end, GroupProvider.ORDERBY_LASTUPDATE);          
        }
        else
        {
            ds = GroupProvider.GetGroup(start, end, GroupProvider.ORDERBY_LASTUPDATE);
 
        }
        this.DataList1.DataSource = ds.Tables[0];
        this.DataList1.DataBind();
    }

    protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {
        AspNetPager1.CurrentPageIndex = e.NewPageIndex;
        LoadGroups((e.NewPageIndex - 1) * 20, 20);
    }
  
    public string GetBrief(object obj)
    {
        string str = obj.ToString();
        return StringUtil.ShortenStr(str); 
    }
}
